/* TransactForm.h
Michael Zahniser, 2008

Header file for the TransactForm class, which represents a form that can be
used to enter transaction information.
*/

#ifndef __GRINGOTTS_TRANSACT_FORM_H__
#define __GRINGOTTS_TRANSACT_FORM_H__

#include "Database.h"

#include "_ncurses/Form.h"



class TransactForm {
public:
	TransactForm(Database &database);

    const string &Run();
    

private:
    // Get all accounts matching the given name prefix.
    const vector<string> &MatchAccountName(const string &prefix);
    // Get the prefix shared by all entries in the given vector,
    // starting with the given character position.
    string CommonPrefix(const vector<string> &names, size_t pos);
    // Guess the account the transfer will be from, based on the history
    // of transfers to the given account.
    string GuessFromAccount(const string &toAccount);


private:
    static bool ValidateDate(string &input, void *);
	static bool CompleteDate(string &input, void *data);
    static bool ValidateMoney(string &input, void *);
    static bool ValidateAccount(string &input, void *);
    static bool CompleteAccount(string &input, void *data);
    static bool EnterToAccount(string &input, void *data);


private:
    Database &database;

	Form form;
	string today;
};

#endif
